<template>
	<view class="cmdq-home">
		<view class="container">
		        <view class="header">
		            <h1>生产物料系统</h1>
		            <p>高效管理您的物料信息，实时跟踪配件库存</p>
		        </view>
		        
		        <view class="cmdq-home">
		            <view class="cmdq-home-header">
		                <!-- 左侧卡片：采退件 -->
		                <u-card class="cmdq-home-header--left" @tap="sendExpressDelivery('add')">
		                    <view class="card-content">
		                        <view class="card-text">
		                            <text class="title">采退件</text>
		                            <text class="desc">采购退货管理</text>
		                        </view>
		                        <u-icon name="arrow-right" color="#666" size="32"></u-icon>
		                    </view>
		                </u-card>
		                
		                <!-- 中间卡片：我发的/我收的 -->
		                <view class="cmdq-home-header--middle">
		                    <u-card class="middle-item sent" @tap="sendExpressDelivery('send')">
		                        <view class="card-content">
		                            <view class="card-text">
		                                <text class="title">我发的</text>
		                                <text class="desc">发出的配件</text>
		                            </view>
		                            <u-icon name="arrow-right" color="#666" size="32"></u-icon>
		                        </view>
		                    </u-card>
		                    
		                    <u-card class="middle-item received" @tap="sendExpressDelivery('received')">
		                        <view class="card-content">
		                            <view class="card-text">
		                                <text class="title">我收的</text>
		                                <text class="desc">收到的配件</text>
		                            </view>
		                            <u-icon name="arrow-right" color="#666" size="32"></u-icon>
		                        </view>
		                    </u-card>
		                </view>
		                
		                <!-- 右侧卡片：待审核/库存看板 -->
		                <view class="cmdq-home-header--right">
		                    <!-- <u-card class="header--right-top" @tap="sendExpressDelivery('toAudit')">
		                        <view class="card-content">
		                            <view class="card-text">
		                                <text class="title">待审核 
										<text class="count-badge">{{auditCount}}</text>
										</text>
		                                <text class="desc">需要审核的订单</text>
		                            </view>
		                            <u-icon name="arrow-right" color="#666" size="32"></u-icon>
		                        </view>
		                    </u-card> -->
							
							 <!-- 发件审核 -->
							    <u-card class="header--right-card audit-sent" @tap="sendExpressDelivery('toAuditSent')">
							        <view class="card-content">
							            <view class="card-text">
							                <text class="title">
							                    发件审核
							                    <text class="count-badge">{{ sendAuditCount }}</text>
							                </text>
							                <text class="desc">待审核的发件订单</text>
							            </view>
							            <u-icon name="arrow-right" color="#666" size="32"></u-icon>
							        </view>
							    </u-card>
							
							    <!-- 收件审核 -->
							    <u-card class="header--right-card audit-received" @tap="sendExpressDelivery('toAuditReceived')">
							        <view class="card-content">
							            <view class="card-text">
							                <text class="title">
							                    收件审核
							                    <text class="count-badge">{{ receivedAuditCount }}</text>
							                </text>
							                <text class="desc">待审核的收件订单</text>
							            </view>
							            <u-icon name="arrow-right" color="#666" size="32"></u-icon>
							        </view>
							    </u-card>
							<!-- 盘点 -->
							<u-card class="header--right-card stock-board" @tap="sendExpressDelivery('contract')">
							    <view class="card-content">
							        <view class="card-text">
							            <text class="title">盘点</text>
							            <text class="desc">盘点数据</text>
							        </view>
							        <u-icon name="arrow-right" color="#666" size="32"></u-icon>
							    </view>
							</u-card>
							    <!-- 库存看板 -->
							    <u-card class="header--right-card stock-board" @tap="sendExpressDelivery('stock')">
							        <view class="card-content">
							            <view class="card-text">
							                <text class="title">库存看板</text>
							                <text class="desc">实时库存状态</text>
							            </view>
							            <u-icon name="arrow-right" color="#666" size="32"></u-icon>
							        </view>
							    </u-card>
								
		                </view>
		            </view>
		            
		            <!-- 底部内容区域 -->
		            <view class="cmdq-home-box">
		                <view class="cmdq-home-box-empty">
		                    <image src="@/static/common/empty.png" class="box-empty--pic" mode="widthFix"></image>
		                </view>
		                <!-- <text class="cmdq-home-box-empty--text">暂无物流信息</text> -->
		                <u-button class="send-express-btn" @click="sendExpressDelivery('add')">去发件</u-button>
						<!-- <u-button class="send-express-btn" @click="sendExpressDelivery('test')">test</u-button> -->
		            </view>
		        </view>
		    </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list1: [{
						name: '单件发货',
					}, {
						name: '批量发货'
				}],
				sendAuditCount : 0,
				receivedAuditCount : 0,
				checkUserList: [],
				      importUserId: [],
				      goodsName: '',
				      options: [
				        {
				          label: '灯具',
				          value: '灯具',
				        }
				      ],
				show: false,
				columns: [
					[]
				],
				file: '请选择',
				length: 1,
				width: 1,
				height: 1,
				isLogin: true,
				xieyi: 'null',
				weight: 1,
				noticeList: ['加盟代理请联系：zs9527gblw', '使用途中出现任何问题请联系客服'],
				seller: [],
				query: [],
				reason: '',
				logList: [],
				uid: 0
			}
		},
		onLoad(options) {

		},
		onShow() {
			var that = this;
			that.isLogin = that.$us.checkLogin();
						this.queryAuditCount();
		},
		methods: {
			queryAuditCount(){
				var that = this;
					that.$http.get('purchaseOrder/auditCount', {
						companyId: that.$us.getCompanyId(),
						pageNo: 1,
						pageSize: 2000
					}, function(res) {
						if (res.success) {
							that.sendAuditCount = res.data.sendAuditCount
							that.receivedAuditCount = res.data.receivedAuditCount
						} 
					})
			},
			sendExpressDelivery(type){
				if(type ==='add'){
					
					uni.switchTab({
						url: `/pages/addPurchase/index`
					})
				}if(type ==='toAuditSent'){
					uni.navigateTo({
						url: `/cmhqPage/purchaseList/purchaseList?type=toAudit`
					})
				}if(type ==='toAuditReceived'){
					uni.navigateTo({
						url: `/cmhqPage/purchaseList/putPurchaseList?type=toAudit`
					})
				}if(type ==='send'){
					uni.navigateTo({
						url: `/cmhqPage/purchaseList/purchaseList`
					})
				}if(type ==='received'){
					uni.navigateTo({
						url: `/cmhqPage/purchaseList/putPurchaseList`
					})
				}if(type ==='stock'){
					uni.navigateTo({
						url: `/cmhqPage/userStockStatis/userStockStatis`
					})
				}if(type ==='contract'){
					uni.navigateTo({
						url: `/cmhqPage/userStockStatis/checkStock`
					})
				}if(type ==='test'){
					uni.navigateTo({
						url: `/pages/test/index`
					})
				}else{
					// uni.navigateTo({
					// 	url: `/cmhqPage/login/login`
					// })
				}
				
				
			}
		},
		onShareAppMessage(res) {
			let that = this;
			var title = '这里寄快递超便宜,5块钱起寄全国,赶紧收藏起来';
			let imageUrl = '/static/share.jpg';
			if (res.from === 'button') {
				//这块需要传参，不然链接地址进去获取不到数据
				return {
					title: title,
					path: '/pages/index/index?uid=' + that.$us.getId(),
					imageUrl: imageUrl
				};
			}
			if (res.from === 'menu') {
				return {
					title: title,
					path: '/pages/index/index' + that.$us.getId(),
					imageUrl: imageUrl
				};
			}
		},
		// 分享到朋友圈
		onShareTimeline() {
			let imageUrl = '/static/share.jpg';
			return {
				title: title,
				path: '/pages/index/index' + that.$us.getId(),
				imageUrl: imageUrl
			};
		}
	}
</script>

<style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        /* 修改后的小程序友好样式 */
        page { /* 小程序根节点替代body */
            background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
            min-height: 100vh;
            padding: 20rpx; /* 单位修正 */
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
            color: #333;
			box-sizing: border-box
        }
        
        .container {
            margin: 0 auto;
            padding: 20rpx; /* 单位修正 */
            box-sizing: border-box;
        }
        
        /* 其他所有固定px单位改为rpx */
        .header h1 {
            font-size: 36rpx; /* 修正单位 */
            margin-bottom: 20rpx; /* 10px -> 20rpx */
        }
        
        .header p {
            font-size: 32rpx; /* 16px -> 32rpx */
        }
        
        /* 卡片相关尺寸修正 */
        .card-text .title {
            font-size: 36rpx; /* 保持原设计比例 */
        }
        
        .header {
            text-align: center;
            margin-bottom: 30px;
            padding: 20px 0;
        }
        
        
        .cmdq-home {
            background: #fff;
            border-radius: 20px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
			box-sizing: border-box;
        }
        
        .cmdq-home-header {
            display: flex;
            margin: 24px;
            height: 360rpx;
            gap: 24rpx;
        }
        
        .cmdq-home-header--left {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: linear-gradient(180deg, #fff9f9, #fbe1e1);
            border-radius: 16rpx;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
            padding: 20rpx;
        }
        
        .cmdq-home-header--left:hover {
            transform: translateY(-5px);
            box-shadow: 0 6rpx 16rpx rgba(230, 155, 63, 0.2);
        }
        
        .cmdq-home-header--right {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 24rpx;
        }
        
        .header--right-top {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-radius: 16rpx;
            background: linear-gradient(270deg, #eadef9, #f7f5fb);
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
            padding: 0 30rpx;
        }
        
        .header--right-top:hover {
            transform: translateY(-3px);
            box-shadow: 0 6rpx 16rpx rgba(138, 99, 210, 0.2);
        }
        
        .header--right-bottom {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-radius: 16rpx;
            background: linear-gradient(270deg, #e0edf5, #f4fbfe);
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
            padding: 0 30rpx;
        }
        
        .header--right-bottom:hover {
            transform: translateY(-3px);
            box-shadow: 0 6rpx 16rpx rgba(63, 155, 230, 0.2);
        }
        
        .cmdq-home-header--middle {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 24rpx;
        }
        
        .middle-item {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-radius: 16rpx;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
            padding: 0 30rpx;
        }
        
        .middle-item.sent {
            background: linear-gradient(270deg, #d1f2eb, #e8f6f3);
        }
        
        .middle-item.received {
            background: linear-gradient(270deg, #fdebd0, #fef5e7);
        }
        
        .middle-item:hover {
            transform: translateY(-3px);
        }
        
        .middle-item.sent:hover {
            box-shadow: 0 6rpx 16rpx rgba(46, 204, 113, 0.2);
        }
        
        .middle-item.received:hover {
            box-shadow: 0 6rpx 16rpx rgba(241, 196, 15, 0.2);
        }
        
        .card-content {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
        }
        
        .card-text {
            display: flex;
            flex-direction: column;
        }
        
        .card-text .title {
            font-size: 36rpx;
            font-weight: 600;
            margin-bottom: 8rpx;
            color: #1a3a5f;
        }
        
        .card-text .desc {
            font-size: 26rpx;
            color: #6c7a89;
        }
        
        .cmdq-home-box {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            padding: 50rpx 0;
            background: #f9fbfd;
            border-top: 1px solid #eee;
        }
        
        .cmdq-home-box-empty {
            margin-bottom: 30rpx;
            text-align: center;
        }
        
        .box-empty--pic {
            width: 240rpx;
            opacity: 0.8;
        }
        
        .cmdq-home-box-empty--text {
            font-size: 28rpx;
            margin-bottom: 40rpx;
            color: #999;
        }
        
        .send-express-btn {
            color: #ffffff;
            background-color: #e69b3f;
            border: 2rpx solid #e69b3f;
            width: 240rpx;
            border-radius: 45rpx;
            padding: 20rpx 0;
            font-size: 32rpx;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4rpx 12rpx rgba(230, 155, 63, 0.3);
            text-align: center;
        }
        
        .send-express-btn:hover {
            background-color: #d18a32;
            transform: translateY(-3px);
            box-shadow: 0 6rpx 16rpx rgba(230, 155, 63, 0.4);
        }
        
        .count-badge {
            background: #e74c3c;
            color: white;
            border-radius: 20rpx;
            padding: 4rpx 16rpx;
            font-size: 24rpx;
            margin-left: 10rpx;
        }
        
        @media (max-width: 768px) {
            .cmdq-home-header {
                flex-direction: column;
                height: auto;
            }
            
            .cmdq-home-header--middle {
                flex-direction: row;
            }
            
            .header--right-top, .header--right-bottom {
                padding: 20rpx;
            }
        }
		
		/* 通用样式 */
		.header--right-card {
		    flex: 1;
		    display: flex;
		    align-items: center;
		    justify-content: space-between;
		    border-radius: 16rpx;
		    cursor: pointer;
		    transition: all 0.3s ease;
		    box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
		    padding: 0 30rpx;
		}
		
		/* 渐变背景区分 */
		.audit-sent {
		    background: linear-gradient(270deg, #d1f2eb, #e8f6f3); /* 清新绿色 */
		}
		.audit-received {
		    background: linear-gradient(270deg, #fdebd0, #fef5e7); /* 温暖黄色 */
		}
		.stock-board {
		    background: linear-gradient(270deg, #e0edf5, #f4fbfe); /* 冷静蓝色 */
		}
		
		/* 悬浮动效 */
		.header--right-card:hover {
		    transform: translateY(-3px);
		}
		.audit-sent:hover {
		    box-shadow: 0 6rpx 16rpx rgba(46, 204, 113, 0.2);
		}
		.audit-received:hover {
		    box-shadow: 0 6rpx 16rpx rgba(241, 196, 15, 0.2);
		}
		.stock-board:hover {
		    box-shadow: 0 6rpx 16rpx rgba(63, 155, 230, 0.2);
		}
		
    </style>
